package com.mindmap.util;

import com.mindmap.model.MindMap;

import java.io.*;

public class FileManager {
    public static void save(MindMap mindMap, File file) {
        try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
            oos.writeObject(mindMap);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static MindMap load(File file) {
        try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
            return (MindMap) ois.readObject();
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
}
